package org.dtrd.modules.patient.entity.bean.report;

import cn.hutool.core.util.RandomUtil;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.control.entity.po.DtrdEntRdSigninTargetDetail;

/**
 * @author qr
 * @date 2022/3/30 14:30
 */
@ApiModel("报告目标")
@Getter
@Setter
public class ReportTargetBean {

    @ApiModelProperty("控制目标名称")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String targetName;

    @ApiModelProperty("目标值")
    private String target;

    @ApiModelProperty("真实值")
    private String value;

    @ApiModelProperty("状态, 0-正常, 1-偏高, 2-偏低")
    private Integer status = RandomUtil.randomInt(0, 3);

    @ApiModelProperty("日期")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String time;

    public ReportTargetBean(DtrdEntRdSigninTargetDetail targetDetail) {
        if (targetDetail.getProjectType() != Constant.TargetProject.DRUG.getType()) {
            Float target = targetDetail.getTargetLow();
            this.target = target.toString();
            Float value = targetDetail.getValue();
            this.value = value.toString();
        }else {
            target = targetDetail.getRemark();
            value = targetDetail.getRemark();
        }
    }

    public static ReportTargetBean buildFirstReportTarget(DtrdEntRdSigninTargetDetail detail) {
        ReportTargetBean target = new ReportTargetBean(detail);
        target.setTargetName(Constant.TargetProject.valueOf(detail.getProjectType()).getName());
        return target;
    }

    public ReportTargetBean(DtrdEntRdSigninTargetDetail targetDetail, String time) {
        this(targetDetail);
        this.time = time;
    }
}
